<?php
$gfunc = new global_function;
@$que = $_GET['q'];
@$q = $gfunc->remove_sign($_GET['q']);
	
//print $gfunc->remove_sign($q);


function cut($str, $len) {
    $str = trim($str);
    if (strlen($str) <= $len) return $str;
    $str = substr($str, 0, $len);
    if ($str != "") {
        if (!substr_count($str, " ")) return $str." ...";
        while (strlen($str) && ($str[strlen($str) - 1] != " ")) $str = substr($str, 0, -1);
        $str = substr($str, 0, -1)." ...";
    }
    return $str;
}	
?>
<link rel="stylesheet" href="css/text_css_hqk.css" type="text/css" />
<p class="group-line">
   <span class="group-title"><?php echo $MULTI_LANG->get_word_by_key('search_result'); ?></span>
</p>
<div class="main_category">
<?php
$result = $exec_mysql->execute("select * from node where title_".$LOCAL." like '%$que%'",0);
while($row = mysql_fetch_array($result))
{
	if($row['id_type'] == 3)
	{
		echo '<div class="list_sub_cat">';
		echo '<div class="hinh"><a href="chi-tiet-san-pham-'.$row['id_ref'].'-'.$gfunc->remove_sign($row['title_'.$LOCAL]).'-'.$row['id'].'.html" ><img src="'.$row['img'].'" width="150px" height="120px" border="0px" alt="'.$row['title_'.$LOCAL].'" title="'.$row['title_'.$LOCAL].'" /></a></div>';
		echo '<div class="xem_tiep"><a href="chi-tiet-san-pham-'.$row['id_ref'].'-'.$gfunc->remove_sign($row['title_'.$LOCAL]).'-'.$row['id'].'.html" >'.cut($row['title_'.$LOCAL],26).'</a></div>';
		echo '</div>';
	}
	elseif($row['id_type'] == 4)
	{
		echo '<div class="list_sub_cat">';
		echo '<div class="hinh"><a href="chi-tiet-du-an-'.$gfunc->remove_sign($row['title_'.$LOCAL]).'-'.$row['id'].'.html" ><img src="'.$row['img'].'" width="150px" height="120px" border="0px" alt="'.$row['title_'.$LOCAL].'" title="'.$row['title_'.$LOCAL].'" /></a></div>';
		echo '<div class="xem_tiep"><a href="chi-tiet-du-an-'.$gfunc->remove_sign($row['title_'.$LOCAL]).'-'.$row['id'].'.html" >'.cut($row['title_'.$LOCAL],26).'</a></div>';
		echo '</div>';
	}
	else
	{
		echo 'Không tìm thấy kết quả!';
	}
}
$count = $exec_mysql->execute("select * from node where title_".$LOCAL." like '%$que%'",2);
if($count == 0)
{
	echo $MULTI_LANG->get_word_by_key('no_result');
}
//echo 'result:'.$count;
?>
</div>
